
import { regConfig } from "../../../../extensions/cocos-scaffold-3x/assets/manger/ConfigManager";
import { FindTargetCondition, HeroActionLogic, EActionLogicState } from "./GpDef";
export namespace GpCfg {
    @regConfig('Action')
    export class Action {
        /**索引 */
        id: number;
        /**描述 */
        desc: string;
        /**动作时间 */
        duration: number;
        /**需要目标 */
        needTarget: boolean;
        /**条件列表 */
        targetConditions: { t: string, o: string, v: string }[];
        /**逻辑列表 */
        logics: { t: string, target: any, tr: number, data: any[], subLogics: any[] }[];
        /**切换动作保持目标 */
        keepTarget: boolean;
        /**下个动作id */
        nextActionId: number;
        /**动画名 */
        aniName: string;
        /**从action配置表项转换成寻找目标条件列表 */
        static toFindTargetConditions(cfg: Action) {
            return cfg.targetConditions.map(condition => {
                return new FindTargetCondition(condition.t, condition.o, condition.v)
            })
        }

        /**从action配置表项转转换成逻辑对象列表 */
        static toLogics(cfg: Action) {
            
            return cfg.logics.map(logic => {
                return Action.cfgLogicToLogic(logic)
            })
        }

        static cfgLogicToLogic(logic: any) {
            const result = new HeroActionLogic(EActionLogicState.doing, logic.tr, logic.t, logic.data, logic.target)
            if (logic.subLogics) {
                result.subLogics = logic.subLogics.map(i => Action.cfgLogicToLogic(i))
            }
            return result
        }
    }

    @regConfig('Skill')
    export class Skill {
        /**索引 */
        id: number;
        /**等级 */
        level: number;
        /**优先级 */
        priority: number;
        /**名称 */
        name: string;
        /**描述 */
        desc: string;
        /**冷却时间 */
        cd: number;
        /**动作id */
        actionId: number;
    }

    @regConfig('Buff')
    export class Buff {
        /**索引 */
        id: number;
        /**描述 */
        desc: string;
        /**持续时间 */
        duration: number;
        /**叠加方式 */
        stackMode: number;
        /**需要目标 */
        needTarget: boolean;
        /**触发间隔 */
        interval: number;
        /**条件列表 */
        targetConditions: number[][];
        /**逻辑列表 */
        startLogics: { t: string, data: number[] }[];
        /**逻辑列表 */
        logics: { t: string, data: number[] }[];
        /**逻辑列表 */
        endLogics: { t: string, data: number[] }[];

        /**附带状态map */
        specailState: {};
    }


}
